<template>
	<view>
		<u-navbar title="店铺" :title-size="35" :title-bold="true" :immersive="true" :background="background"
			:border-bottom="false"></u-navbar>
		<view style="height: 100vh;background: linear-gradient(90deg, #4FFFA8 0%, #63FBCC 100%);position: relative;">
			<view style="width: 100%; height: auto;;position: absolute; top: 100px;">
				<view class="shop">
					<view class="shop-item" v-for="item in shopList"  @click="opentable(item)">
						<view class="item-lf">
							<view class="lf-img">
								<image src="https://gongxiangtaiqiu.axa2.com/taiqiu/shopimg.png"
									style="width:100%;height: 100%;"></image>
							</view>
						</view>
						<view class="item-rg">
							<view class="rg-flex">
								<view class="title">
									{{item.f_shop_name}}
								</view>
								<view class="opentab">
									<view class="opentab-p">
										去开台
									</view>
								</view>
							</view>
							<view class="rg-center">
								<view class="address">
									{{item.f_address}}
								</view>
								<view class="distance">
									{{item.f_length}}m
								</view>
							</view>
							<!-- 进度条 -->
							<view class="">
								<u-line-progress active-color="#8CFF80" :percent="item.percent" :show-percent="false"
									:height="15"></u-line-progress>
							</view>
							<view class="vacancy">
								<view class="vacancy-lf">
									空位：{{item.downNum}}
								</view>
								<view class="vacancy-rg">
									总位：{{item.allNum}}
								</view>
							</view>

						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: 'rgba(0,0,0,0)',
				},
				shopList:[],
				percent:'',
			};
		},
		onLoad() {
			this.$Api.shopList({
				type: 3,
				page: 1,
				pageNum: 15,
				lon: uni.getStorageSync('longitude'),
				lat: uni.getStorageSync('latitude'),
			}).then(res => {
				// this.shopList = res.data.data
				let arr = res.data.data
				this.shopList= arr.map((item)=>{
					return{
						...item,
						percent:item.allNum==0?0:((item.allNum-item.downNum)/item.allNum).toFixed(2)*100
					}
				})
				console.log(this.shopList)

			})
		},
		methods: {
			opentable(item) {
				uni.navigateTo({
					url: '../opentable/opentable?item='+JSON.stringify(item)
				})
			},

		},
		mounted() {

		}
	}
</script>

<style lang="scss">
	page{
		background: linear-gradient(90deg, #4FFFA8 0%, #63FBCC 100%);
	}
	.shop {
		width: 100%;
		height: auto;
		min-height: 700rpx;

		.shop-item {
			width: 690rpx;
			height: 220rpx;
			// box-shadow: 0px 0px 20rpx 0px rgba(223, 223, 223, 0.3);
			border-radius: 20rpx;
			margin: auto;
			margin-top: 40rpx;
			display: flex;
			background-color: #ffffff;

			.item-lf {
				width: 180rpx;
				height: 220rpx;
				display: flex;
				justify-content: center;
				padding-top: 30rpx;

				.lf-img {
					width: 130rpx;
					height: 130rpx;
				}
			}

			.item-rg {
				width: 500rpx;
				height: 220rpx;

				.rg-flex {
					width: 500rpx;
					height: 60rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;


					.title {
						// width: 158rpx;
						height: 40rpx;
						font-size: 32rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #222222;
						margin-top: 20rpx;
						 width: 440rpx;
						 white-space: nowrap; 
						 overflow: hidden;
						 text-overflow: ellipsis;
					}

					.opentab {
						margin-top: 30rpx;
						width: 126rpx;
						height: 52rpx;
						background: #222222;
						border-radius: 26rpx;
						display: flex;
						justify-content: center;
						align-items: center;

						.opentab-p {
							// width: 71rpx;
							// height: 28rpx;
							font-size: 24rpx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #02FF83;
						}
					}
				}
				
				
				.schedule {
					width: 250rpx;
					height: 14rpx;
					background: linear-gradient(90deg, #8CFF80 0%, #5FFF95 100%);
					border-radius: 7rpx 0px 0px 7rpx;
					margin-top: 16rpx;
				}
				.vacancy {
					width: 480rpx;
					height: 40rpx;
					display: flex;
					justify-content: space-between;
					margin-top: 13rpx;

					.vacancy-lf {}

					.vacancy-rg {}
				}

				.rg-center {
					width: 480rpx;
					height: 50rpx;
					display: flex;
					justify-content: space-between;
					margin-top: 10rpx;

					.address {
						width: 320rpx;
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #999999;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
					}

					.distance {
						// width: 87rpx;
						height: 17rpx;
						font-size: 22rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #999999;
						line-height: 72rpx;
					}
				}
			}
		}
	}
</style>
